package org.extremengine.common;

import org.extremengine.shape.Shape;

/**
 * 无需外力作用即可自发运动的刚体对象，例如：用户控制的游戏主角人物，汽车等。
 * @author yuxing
 *
 */
public class ActiveBody extends RigidBody {
	
	// 是否跳起？
	boolean isJumping = false;
	
	Velocity walkVelocity = new Velocity(0);

	public ActiveBody(double friction, double elasticity, int mass, Shape shape) {
		super(friction, elasticity, mass, shape);
	}
	
	/**
	 * 
	 */
//	@Override
//	public void transform(long timePeirod) {
//		super.transform(timePeirod);
//		this.shape.transform(walkVelocity, timePeirod);
//	}

	/**
	 * 以speed的速度行走。
	 * @param speed
	 */
	public void walk(double speed) {
		walkVelocity.setSpeedx(speed);
	}
	
	/**
	 * 朝指定方向跳跃。 
	 * @param v
	 */
	public void jump(Velocity v) {
		isJumping = true;
		this.setV(v);
	}
	
	/**
	 * 向上跳跃。Jump upward
	 * @param speed
	 */
	public void jump(int speed) {
		isJumping = true;
		if(getV() == null) {
			this.setV(new Velocity(speed, 0));
		}
		else {
			getV().setSpeedy(speed);
		}
		
	}

}
